package com.shujia.map_;

import org.junit.Test;

import java.util.Map;
import java.util.TreeMap;

public class TreeMapDemo {


    @Test
    public void test2() {
        Map<Person, Double> stuScore = new TreeMap<>();

        // TreeMap, 排序是针对key, 跟value是没有关系
        stuScore.put(new Person("d小明"), 70D);
        stuScore.put(new Person("c小花"), 80D);
        stuScore.put(new Person("a小帅"), 90D);
        stuScore.put(new Person("e小夫"), 59D);

        System.out.println(stuScore);
    }

    @Test
    public void test1() {
        Map<String, Double> stuScore = new TreeMap<>();

        stuScore.put("d小明", 70D);
        stuScore.put("c小花", 80D);
        stuScore.put("a小帅", 90D);
        stuScore.put("e小夫", 59D);

//        for (Map.Entry<String, Double> entry : stuScore.entrySet()) {
//            System.out.println("key:" + entry.getKey());
//            System.out.println("value:" + entry.getValue());
//        }

        System.out.println(stuScore);


    }
}
